home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / Palm Finder 2 / Src / App Sources / events.cpp < prev    next >
Encoding:
Text File  |  2001-06-23  |  1.8 KB  |  98 lines

  1. // events.cpp
  2.  
  3. #include "events.h"
  4. #include "drawing.h"
  5. #include "Finder_res.h"
  6.  
  7. // timing constants
  8. const int beep_ms = 250;
  9. const int after_beep_ms = 500;
  10. const int happy_ms = 3000;
  11. const int welcome_ms = 3000;
  12.  
  13.  
  14. //
  15. // send_menu_event()
  16. //
  17. void send_menu_event(int id, Boolean pen_down, int x, int y) {
  18.     EventType event;
  19.     
  20.     event.eType =         menuEvent;
  21.     event.penDown =     pen_down;
  22.     event.screenX =        x;
  23.     event.screenY =        y;
  24.     event.data.menu.itemID =    id;
  25.     
  26.     EvtAddEventToQueue (&event);
  27. }
  28.  
  29. //
  30. // send_update_event()
  31. //
  32. void send_update_event() {
  33.     int    id = FrmGetActiveFormID();
  34.     
  35.     FrmUpdateForm (id, frmRedrawUpdateCode);
  36. }
  37.  
  38. //
  39. // sys_beep()
  40. //
  41. void sys_beep(int duration) { // in milliseconds
  42.     // constants
  43.     const UInt32            note_frequency = 880; // hertz
  44.     
  45.     // variables
  46.     UInt32                    volume;
  47.     Err                        err;
  48.     SndCommandType    cmd;
  49.     
  50.     // instructions
  51.     volume = PrefGetPreference(prefSysSoundVolume);
  52.     cmd.cmd = sndCmdFrqOn;
  53.     cmd.param1 = note_frequency; // hertz
  54.     cmd.param2 = duration; // milliseconds
  55.     cmd.param3 = volume;
  56.     err = SndDoCmd(NULL, &cmd, 0);
  57. }
  58.  
  59.  
  60. //
  61. // delay()
  62. //
  63. void delay(int duration) { // in milliseconds
  64.     Int32    ticks_per_sec = SysTicksPerSecond();
  65.     Int32    total_ticks = Int32 ( ticks_per_sec * Int32(duration) / 1000);
  66.     Err        err;
  67.     
  68.     err = SysTaskDelay (total_ticks);
  69. }
  70.  
  71.  
  72. //
  73. // startup_sequence()
  74. //
  75. void startup_sequence() {
  76.     // variables
  77.     FormPtr frmP;
  78.  
  79.     // show blank startup screen
  80.     frmP = FrmInitForm(StartupForm);
  81.     if (frmP==NULL) return;
  82.     FrmDrawForm(frmP);
  83.     // beep for one quarter second
  84.     sys_beep(beep_ms);
  85.     delay(after_beep_ms);
  86.     // show happy mac for one second
  87.     draw_bitmap(StartupHappyMacBitmap, 0, 0, left_align, top_align);
  88.     delay(happy_ms);
  89.     // show welcome msg for five seconds
  90.     draw_bitmap(StartupWelcometoMacBitmap, 0, 0, left_align, top_align);
  91.     delay(welcome_ms);
  92.     // delete form
  93.     FrmDeleteForm(frmP);
  94.     
  95. }
  96.  
  97.  
  98.